import request from '../../utils/request'

const state = {
	test: '测试数据',

	// 后端返回数据
	indexData: {}, //首页数据
}
const mutations = {
	//修改首页数据
	changeIndexDataMutations(state, indexData) {
		state.indexData = indexData;
	}
}
const actions = {
	// 发送网络请求 获取首页数据
	async getIndexDataActions({
		commit
	}) {
		// 1.执行异步任务，发送网络请求
		const res = await request('/getIndexData');
		// console.log('----', res);
		// 2.commit 触发mutations
		commit('changeIndexDataMutations', res.data)
	}
}
const getters = {

}

export default {
	namespaced: true,
	state,
	mutations,
	actions,
	getters
}